package com.midele.goodstuff.navigation

import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.foundation.pager.PagerState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.midele.goodstuff.ui.main.screen.ExploreRoute
import com.midele.goodstuff.ui.main.screen.HomeRoute
import com.midele.goodstuff.ui.main.screen.MineRoute
import com.midele.goodstuff.ui.main.screen.RecordRoute
import com.midele.goodstuff.ui.record.RecordFirstRoute
import com.midele.goodstuff.ui.releasegoods.screen.ItemCategoryRoute
import com.midele.goodstuff.ui.releasegoods.screen.ReleaseMethodRoute
import com.midele.goodstuff.ui.search.screen.SearchRoute

const val exploreRoute = "explore"
const val recordRoute = "record"
const val mineRoute = "mine"
const val searchRoute = "search"
const val recordFirstRoute = "record_first"
//选择发布
const val publishActivity = "publish_activity"

//发布新物品
const val publishNewThing = "publish_new_thing"

@Composable
fun MidNavHost(
    navController: NavHostController,
    startDestination: String = "app_index",
    modifier: Modifier,
    pageState: PagerState,

) {
    NavHost(
        navController = navController,
        startDestination = startDestination,
        modifier = modifier,
        popEnterTransition = {
            scaleIn(
                animationSpec = tween(
                    durationMillis = 500,
                    delayMillis = 35,
                ),
                initialScale = 1.1F,
            ) + fadeIn(
                animationSpec = tween(
                    durationMillis = 500,
                    delayMillis = 35,
                ),
            )
        },
        popExitTransition = {
            scaleOut(
                targetScale = 0.9F,
            ) + fadeOut(
                animationSpec = tween(
                    durationMillis = 35,
                    easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f),
                ),
            )
        },
    ) {
        composable("app_index") {
            HomeRoute(modifier = Modifier, navController = navController, pageState = pageState)
        }
        composable(exploreRoute) {
            ExploreRoute(modifier = Modifier, navController = navController)
        }
        composable(recordRoute) {
            RecordRoute(modifier = Modifier, navController = navController)
        }
        composable(mineRoute) {
            MineRoute(modifier = Modifier, navController = navController)
        }
        composable(searchRoute) {
            SearchRoute(modifier = Modifier, navController = navController)
        }

        composable(recordFirstRoute) {
            RecordFirstRoute(modifier = Modifier, navController = navController)
        }

        composable(publishActivity){
            ReleaseMethodRoute(modifier = Modifier,navController = navController)
        }
        composable(publishNewThing){
            ItemCategoryRoute(modifier = Modifier,navController = navController)
        }
    }
}
